package Entity;

/**
 * 练习记录实体类：修复 userAnswer 类型（int→Integer），支持 null 未答题状态
 */
public class PracticeRecord {
    private String exerciseId;    // 关联的习题ID
    private Integer userAnswer;   // 改为 Integer（支持 null，代表未答题）
    private boolean isCompleted;  // 是否完成
    private String answerTime;    // 答题时间

    // 修复构造函数：userAnswer 类型改为 Integer
    public PracticeRecord(String exerciseId, Integer userAnswer, boolean isCompleted, String answerTime) {
        if (exerciseId == null || exerciseId.trim().isEmpty()) {
            throw new IllegalArgumentException("习题ID不能为空");
        }
        this.exerciseId = exerciseId;
        this.userAnswer = userAnswer; // 可接收 null（未答题）
        this.isCompleted = isCompleted;
        this.answerTime = answerTime;
    }

    // Getter 和 Setter 方法（同步改为 Integer）
    public String getExerciseId() { return exerciseId; }
    public Integer getUserAnswer() { return userAnswer; } // 返回 Integer，支持 null
    public void setUserAnswer(Integer userAnswer) { this.userAnswer = userAnswer; }
    public boolean isCompleted() { return isCompleted; }
    public void setCompleted(boolean completed) { isCompleted = completed; }
    public String getAnswerTime() { return answerTime; }
    public void setAnswerTime(String answerTime) { this.answerTime = answerTime; }
}